package com.example.score.service;

import com.example.score.dto.questionFile.ExamQuestionFileDTO;
import com.example.score.entity.ExamQuestionFile;
import com.example.score.mapper.ExamQuestionFileMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ExamQuestionFileService {
    private final ExamQuestionFileMapper examQuestionFileMapper;


    public List<ExamQuestionFile> list(ExamQuestionFileDTO examQuestionFileDTO) {
        return examQuestionFileMapper.list(examQuestionFileDTO);
    }

    public int add(ExamQuestionFile examQuestionFile) {
        if (ObjectUtils.isEmpty(examQuestionFile.getQuestionId()) || ObjectUtils.isEmpty(examQuestionFile.getExamId())
                || ObjectUtils.isEmpty(examQuestionFile.getTeacherId()) || ObjectUtils.isEmpty(examQuestionFile.getFilePath())) {
            return 0;
        }
        return examQuestionFileMapper.insertSelective(examQuestionFile);
    }

    public int delete(Long[] ids) {
        return examQuestionFileMapper.deleteByIds(ids);
    }
}
